package com.mic.yzzn.plc.model;


import com.mic.yzzn.plc.common.toolUtils.PLCContactorCode;
import com.mic.yzzn.plc.common.toolUtils.PLCDataCode;

public class ContactSection {

	/** 点位的类型 */
	private String type;
	/** 起始地址 */
	private String startPoint;
	/** 结束地址 */
	private String endPoint;
	
	public ContactSection(){}
	
	/**
	 * @param startTypeAndPoint e.g. R2000
	 * @param endTypeAndPoint e.g. R2050
	 */
	public ContactSection(String startTypeAndPoint, String endTypeAndPoint){

		this(startTypeAndPoint.substring(0, 1),
				startTypeAndPoint.substring(1, startTypeAndPoint.length()),
				endTypeAndPoint.substring(1, endTypeAndPoint.length()));

		String beginType= startTypeAndPoint.substring(0, 1);
		String endType = endTypeAndPoint.substring(0, 1);

		if (!beginType.equals(endType)) {
			throw new IllegalArgumentException("the type of datasection must be same");
		}
	}
	
	/**
	 * 
	 * @param type R or D
	 * @param startPoint e.g. 2000
	 * @param endPoint e.g. 2050
	 */
	public ContactSection(String type, String startPoint, String endPoint) {
		this.type = type;
		this.startPoint = startPoint;
		this.endPoint = endPoint;
	}

	// getters and setters
	
	@Override
	public String toString() {
		return "ContactSection [type=" + type + ", startPoint=" + startPoint
				+ ", endPoint=" + endPoint + "]";
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	public String getStartPoint() {
		return startPoint;
	}

	public void setStartPoint(String startPoint) {
		this.startPoint = startPoint;
	}

	public String getEndPoint() {
		return endPoint;
	}

	public void setEndPoint(String endPoint) {
		this.endPoint = endPoint;
	}
	
	
}
